$(function() {
	var tou1 = {
		complain_type: 1
	};
	var tou2 = {
		complain_type: 2
	};

	// 男数据加载 （投诉）
	var complaints_y = [
	    {    //时间
			data: "complain_time"
		},
		{  //投诉人
			data: function(obj) {
				$nick = "";
				$nick = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'>" +
					"<i>" + obj.boy_nick + "</i><span style='display: none'>b"+obj.boy_id+"</span>" +
					"</a>";
				return $nick
			}
		},
		{    //被投诉人
			data: function(obj) {
				$nick = "";
				$nick = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'>" +
					"<i>" + obj.girl_nick + "</i><span style='display: none'>g"+obj.girl_id+"</span>" +
					"</a>";
				return $nick
			}
		},
		{    //投诉原因
			data: "complain_reason"
		},
		{    // 投诉消息内容
			data : function(obj){
				$contt = "";
				$contt =""+obj.complain_content+"";
				return $contt
			}
		},
		{    //投诉图片 （可能会没有）
			data : function(obj){
				$cas_img = "";
				if(obj.img_url == ""){
						$cas_img = "无图片";
						return $cas_img
				}else{
						$cas_img ="<a href='Javascript:;' ><img class='pimg' width='80px' height='80px' src='"+obj.img_url+"'/></a>";
			
							return $cas_img
				}
			
				
			}
		},
		{    //  处理操作
			data : function(obj){
				   $btn_cc = "";
				   if (obj.complain_state==1) {
				   	   $btn_cc = "<a href='Javascript:;'  class='btn btn-small complaints_handling' data-toggle='modal' data-target='#Weirdo' >处理 <span style='display:none'>"+obj.boy_complain_id+"</span></a>";
				   return $btn_cc
				   } else{
				   	var str = obj.handle_content; //原始字符串
				   	var s = str; //要展示的字符串
				   	if(obj.handle_content == ""){
				   		$dindang = "";
				   		$dindang = "<div data-toggle='modal' data-target='#Weirdo'  class='Weirdo_div' >"+
				   		"<span>无备注</span><b style='display:none'>"+obj.boy_complain_id+"</b><div style='display:none'>无备注</div></div>";
				   		return $dindang
				   	}
				   	if(str.length > 10) {
				   		s = str.substring(0, 10) + "...";
				   		$dindang = "";
				   		$dindang = "<div style='position:relative' data-toggle='modal' data-target='#Weirdo' class='Weirdo_div' >" +
				   			"<span class='xcontent'>" + s + "</span><b style='display:none'>"+obj.boy_complain_id+"</b>" +
				   			"<div style='display:none;position:absolute'>" + obj.handle_content + "</div>" +
				   			"</div>";
				   			show_beizhu () ;
				   		return $dindang
				   	} else {
				   		$dindang = "";
				   		$dindang = "<div data-toggle='modal' data-target='#Weirdo'  class='Weirdo_div' ><span>" + obj.handle_content + "</span><div style='display:none'>" + obj.handle_content + "</div><b style='display:none'>"+obj.boy_complain_id+"</b></div>";
				   		return $dindang
				   	}
				   }
				
			}
		}
		
	];
	// 女数据加载 （管理）

	var complaints_x = [
	    {    //时间
			data: "complain_time"
		},
		{  //投诉人
			data: function(obj) {
				$nick = "";
				$nick = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'>" +
					"<i>" + obj.girl_nick + "</i><span style='display: none'>g"+obj.girl_id+"</span>" +
					"</a>";
				return $nick
			}
		},
		{    //被投诉人
			data: function(obj) {
				$nick = "";
				$nick = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'>" +
					"<i>" + obj.boy_nick + "</i><span style='display: none'>b"+obj.boy_id+"</span>" +
					"</a>";
				return $nick
			}
		},
		{    //投诉原因
			data: "complain_reason"
		},
		{    // 投诉消息内容
			data : function(obj){
				$contt = "";
				$contt =""+obj.complain_content+"";
				
				return $contt
			}
		},
		{    //投诉图片 （可能会没有）
			data : function(obj){
				$cas_img = "";
				if(obj.img_url == ""){
						$cas_img = "无图片";
						return $cas_img
				}else{
						$cas_img ="<a href='Javascript:;' ><img class='pimg' width='80px' height='80px' src='"+obj.img_url+"'/></a>";
		
							return $cas_img
				}
			
				
			}
		},
		{    //  处理操作
			data : function(obj){
				   $btn_cc = "";
				   if (obj.complain_state==1) {
				   	   $btn_cc = "<a href='Javascript:;'  class='btn btn-small complaints_handling'  data-toggle='modal' data-target='#Weirdo' >处理 <span style='display:none'>"+obj.girl_complain_id+"</span></a>";
				   return $btn_cc
				   } else{
				   	var str = obj.handle_content; //原始字符串
				   	var s = str; //要展示的字符串
				   	if(obj.handle_content == "") {
				   		$dindang = "";
				   		$dindang = "<div data-toggle='modal' data-target='#Weirdo'  class='Weirdo_div' >" +
				   			"<span>无备注</span><b style='display:none'>" + obj.girl_complain_id + "</b><div style='display:none'>无备注</div></div>";
				   			return $dindang
				   	}
				   	if(str.length > 10) {
				   		s = str.substring(0, 10) + "...";
				   		$dindang = "";
				   		$dindang = "<div style='position:relative'  data-toggle='modal' data-target='#Weirdo' class='Weirdo_div' >" +
				   			"<span class='xcontent'>" + s + "</span>"+
				   			"<div style='display:none;position:absolute'>" + obj.handle_content + "</div><b style='display:none'>"+obj.girl_complain_id+"</b>" +
				   			"</div>";
				   				show_beizhu () ;
				   		return $dindang
				   	} else {
				   		$dindang = "";
				   		$dindang = "<div data-toggle='modal' data-target='#Weirdo' class='Weirdo_div' >"+
				   		"<span>" + obj.handle_content + "</span><b style='display:none'>"+obj.girl_complain_id+"</b>"+
				   		"<div style='display:none'>" + obj.handle_content + "</div></div>";
				   		return $dindang
				   	}
				   }
				
			}
		}
		
	];
	//建议  （男）
	var suggest_y = [
	 {  //时间
			data: "complain_time"
	 },
	 {  //提交人
			data: function(obj) {
				$nick = "";
				$nick = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'>" +
					"<strong>" + obj.boy_nick + "</strong><span style='display: none'>b"+obj.boy_id+"</span>" +
					"</a>";
				return $nick
			}
	 	
	 },
	 {   //消息内容
	 		data : function(obj){
	 			var str = obj.complain_content; //原始字符串
	 			var s = str; //要展示的字符串
	 			if(str.length > 10) {
	 				s = str.substring(0, 10) + "...";
	 				$dindang = "";
	 				$dindang = "<div style='position:relative'>" +
	 					"<span class='xcontent'>" + s + "</span>" +
	 					"<div style='display:none;position:absolute'>" + obj.complain_content + "</div>" +
	 					"</div>";
	 				return $dindang
	 			} else {
	 				$dindang = "";
	 				$dindang = "<div><span>" + obj.complain_content + "</span><div style='display:none'>" + obj.complain_content + "</div></div>";
	 				return $dindang
	 			}
			}
	 },
	 {   //图片
	 		data : function(obj){
				$cas_img = "";
				if(obj.img_url == ""){
						$cas_img = "无图片";
						return $cas_img
				}else{
						$cas_img ="<a href='Javascript:;' ><img class='pimg' width='80px' height='80px' src='"+obj.img_url+"'/></a>";
			
							return $cas_img
				}
			
				
			}
	 },
	 {
	 	data: function(obj){
	 		var bdd = obj.boy_id;
	 		var huid = "b" +bdd;
          $xiaox="<button class='btn xiaoxi-fasong' data-toggle='modal' data-target='#mymodal-liaot'>发送消息<span style='display:none'>"+huid+"</span></button>";
          return $xiaox;
      } 
	 }
	];
	//建议  （女）
	var suggest_x = [{ //时间
			data: "complain_time"
		},
		{ //提交人
			data: function(obj) {
				$nick = "";
				$nick = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'>" +
					"<strong>" + obj.girl_nick + "</strong><span style='display: none'>g" + obj.girl_id + "</span>" +
					"</a>";
				return $nick
			}
	
		},
		{ //消息内容
			data: function(obj) {
				var str = obj.complain_content; //原始字符串
				var s = str; //要展示的字符串
				if(str.length > 10) {
					s = str.substring(0, 10) + "...";
					$dindang = "";
					$dindang = "<div style='position:relative'>" +
						"<span class='xcontent'>" + s + "</span>" +
						"<div style='display:none;position:absolute'>" + obj.complain_content + "</div>" +
						"</div>";
					return $dindang
				} else {
					$dindang = "";
					$dindang = "<div><span>" + obj.complain_content + "</span><div style='display:none'>" + obj.complain_content + "</div></div>";
					return $dindang
				}
			}
		},
		{ //图片
			data: function(obj) {
				$cas_img = "";
				if(obj.img_url == "") {
					$cas_img = "无图片";
					return $cas_img
				} else {
					$cas_img = "<a href='Javascript:;' ><img class='pimg' width='80px' height='80px' src='" + obj.img_url + "'/></a>";
		
					return $cas_img
				}
	
			}
		},
		{
			data: function(obj) {
				var bdd = obj.girl_id;
				var huid = "g" + bdd;
				$xiaox = "<button class='btn xiaoxi-fasong' data-toggle='modal' data-target='#mymodal-liaot'>发送消息<span style='display:none'>" + huid + "</span><small  style='display:none'>"+obj.girl_nick+"</small></button>";
				return $xiaox;
			}
		}
	];
	
	var sex = "";

 
	$(".ts-head>div:first-child").click(function(){     //点击女生投诉管理
	
		$(this).css({"background":"red","color":"white"});
		$(this).next().css({"background":"gainsboro","color":"black"});
		sex = 2;
		Data_table("#complaints_table", address1 + "/admin/complain/girlMain", complaints_x, false, tou1,7);
		Data_table("#suggest_table", address1 + "/admin/complain/girlMain", suggest_x, false, tou2,7);
		     	show_beizhu () ;
	});
	$(".ts-head>div:last-child").click(function() {     //点击男生投诉管理
	
		$(this).css({"background": "red","color": "white"});
		$(this).prev().css({"background": "ghostwhite","color":"black"});
		sex = 1;
		Data_table("#complaints_table", address1 + "/admin/complain/boyMain", complaints_y, false, tou1,7);
		Data_table("#suggest_table", address1 + "/admin/complain/boyMain", suggest_y, false, tou2,7);
		show_beizhu () ;
	});
	$(".toushu").click(function () {  //点击投诉反馈加载女生的
	
		$(".ts-head>div:first-child").css({"background":"red","color":"white"});
		$(".ts-head>div:first-child").next().css({"background":"gainsboro","color":"black"})
		Data_table("#complaints_table", address1 + "/admin/complain/girlMain", complaints_x, false, tou1,7);
		Data_table("#suggest_table", address1 + "/admin/complain/girlMain", suggest_x, false, tou2,7);
		sex = 2;
			show_beizhu () ;
	});
	
	$("#complaints_table").ajaxComplete(function() {  //点击处理操作
			mroe_img ();
		$(".complaints_handling").unbind("click").on("click", function() {
			$("#Weirdo").modal("hide");
			$("#Weirdo_con").val("");
			var complain_id = $(this).find("span").text();
		
			$(".Weirdo_tj").unbind("click").on("click", function() {
				var complain_con = $("#Weirdo_con").val();
				var send_da = {
					complain_id: complain_id,
					handle_content: complain_con,
					sex: sex
				}

			TJ_ajax_fahuo(address1 + "/admin/complain/setState", send_da, "#Weirdo", "#complaints_table");
			} )
		})
	});
		$("#suggest_table").ajaxComplete(function() { 
				mroe_img ();
				show_beizhu ()
		
		});
		function show_beizhu () {
			$(".xcontent").parent().parent().hover(function() {
			
				$(this).find($(".xcontent")).css("opacity", 0);
				$(this).find($(".xcontent")).next().css({
					"display": "block",
					"top": "-10px",
					"background": "white",
					"z-index": 9999
				});
			}, function() {
				$(this).find($(".xcontent")).css("opacity", 1);
				$(this).find($(".xcontent")).next().css("display", "none")
			})
		};
		$("#complaints_table").ajaxComplete(function() { //点击 修改 处理操作
		$(".Weirdo_div").unbind("click").on("click",function () {
		 $("#Weirdo_con").val($(this).find("div").text());
		 var cce_id = $(this).find("b").text();
		
		 $(".Weirdo_tj").unbind("click").on("click",function () {
		 	 var cce = $("#Weirdo_con").val();
		 	var send_comit = {
		 		complain_id: cce_id,
		 		handle_content: cce,
		 		sex: sex
		 	};
		
	   	TJ_ajax_fahuo(address1 + "/admin/complain/setComplainHandle", send_comit, "#Weirdo", "#complaints_table");
	  })
		})
	})
	
})